package Thread;

public class shop {
    public void buy(){
        try{
            Thread t=Thread.currentThread();
            System.out.println(t.getName()+"正在挑衣服...");
            Thread.sleep(5000);
            synchronized (this) {
                System.out.println(t.getName() + "正在试衣服...");

                Thread.sleep(5000);
            }
            System.out.println(t.getName()+"结账离开...");
        }catch (InterruptedException e){

        }
    }

    public static void main(String[] args) {
        Thread t1=new Thread("王克晶");
        Thread t2=new Thread("范传奇");
        t1.getName();
        t2.getName();
        t1.start();
        t2.start();

    }
}
